package fristphase.day9_14;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class CollectionToArray {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        System.out.println(c);

        String[] array = c.toArray(new String[0]);
        array[2] = "物";//验证新的数组对象不会影响原Collection对象
        String str =  array[0];
        System.out.println(array);//引用类型的变量被直接输出会默认调用Object的toString方法
        System.out.println(Arrays.toString(array));//数组引用类型重写了toString方法
        System.out.println(c);
    }
}
